package person.twj.securitysessionredis.core.security.handler;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import java.io.IOException;

public class MyLogoutSuccessHandler implements LogoutSuccessHandler {
    private RedirectStrategy redirectStrategy;
    public MyLogoutSuccessHandler() {
        this.redirectStrategy = new DefaultRedirectStrategy();
    }
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
//        @TODO 登录退出的业务操作，例如，成功登录后，


        this.redirectStrategy.sendRedirect(request,response,"/login");


    }
}
